class BaseException(Exception):
    pass


class DerivedException(BaseException):
    pass


# try:
#     raise DerivedException
#     pass
# except DerivedException:
#     print("derived exception")
#     raise
# except BaseException:
#     print('Base exception')  # 不会执行到。因为 Base 是 Derived 父类，就是同样异常。已经被捕获一次，不会再被捕获
# except DerivedException:
#     print("derived exception")  # 也不会出现
# except:
#     print("all exception")

try:
    try:
        raise DerivedException
        pass
    except DerivedException:
        print("derived exception")
        raise
    except BaseException:
        # 不会执行到。因为 Base 是 Derived 父类，就是同样异常。已经被捕获一次，不会再被捕获
        print('Base exception')
    except DerivedException:
        print("derived exception")  # 也不会出现
except BaseException:
    print("catched by base2")
except:
    print("catched by all except 2")
"""
derived exception
catched by base2
外部可以补充已经被捕获的异常
"""
